package com.bfsoft.springbootinit.pojo.vo;

import lombok.Data;

/**
 * @author ma
 */
@Data
public class ResultVO <T> {


    private String code;

    private String message;

    private T data;

    public static <T> ResultVO<T> ok(T data){
        return resultVO(data,"0000",null);
    }

    public static <T> ResultVO<T> ok(String message ){
        return resultVO(null,"0000",message);
    }

    public static <T> ResultVO<T> ok(T data,String message ){
        return resultVO(data,"0000",message);
    }


    public static <T> ResultVO<T> fail(T data,String message ){
        return resultVO(data,"1111",message);
    }

    public static <T> ResultVO<T> fail(String message ){
        return resultVO(null,"1111",message);
    }

    private static <T> ResultVO<T> resultVO(T data,String code,String message){
        ResultVO<T> resultVO=new ResultVO<>();
        resultVO.setCode(code);
        resultVO.setData(data);
        resultVO.setMessage(message);
        return resultVO;
    }

    public ResultVO ( String code , String message , T data ) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ResultVO () {
    }
}
